package com.im.partchat.adapter.learn;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.im.partchat.R;
import com.im.partchat.adapter.base.XRecyclerViewAdapter;
import com.im.partchat.adapter.base.XViewHolder;
import com.im.partchat.bean.learn.Tab7New;

import java.util.List;

/**
 * Created by flyou on 2017/6/30.
 * VersionCode: 1
 * Desc:
 */

public class NewTab7FragmentAdapter extends XRecyclerViewAdapter<Tab7New> {
    private Context context;
    private OnQrCodeClickListener myQrCodeClickListener;

    public NewTab7FragmentAdapter(Context context, @NonNull RecyclerView mRecyclerView, List<Tab7New> dataLists) {
        super(mRecyclerView, dataLists, R.layout.view_learn_tab7_item);
        this.context = context;
    }

    @Override
    protected void bindData(XViewHolder holder, final Tab7New data, int position) {
        holder.setImageUrl(context, R.id.iv_wechat, data.getTitleUrl(), R.drawable.img_pic_default);
        holder.setImageUrl(context, R.id.iv_image, data.getUrl(), R.drawable.img_rectangle_pic_default);
        holder.setText(R.id.tv_wechat_name, data.getTitle());
        holder.setText(R.id.tv_wechat_desc, data.getDesc());
        holder.setOnClickListener(R.id.iv_wechat, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (myQrCodeClickListener != null) {
                    myQrCodeClickListener.OnQrCodeClickListener(data);
                }
            }
        });


    }

    public void setOnQrCodeClickListener(OnQrCodeClickListener onImageClickListener) {
        myQrCodeClickListener = onImageClickListener;

    }

    public interface OnQrCodeClickListener {
        void OnQrCodeClickListener(Tab7New tab7New);
    }
}
